package edu.hcnu;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description:
 * @author: Administrator
 * @time: 2023/4/29 18:05
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("统一返回格式")

public class ApiResult {
    @ApiModelProperty(value = "状态码", required = true, example = "200")

    private Integer code;
    @ApiModelProperty(value = "消息", required = true, example = "这是接口反馈消息")

    private String msg;
    @ApiModelProperty(value = "数据", required = true, example = "这是接口返回数据")

    private Object data;

    public ApiResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ApiResult success(Integer code, String msg, Object data) {
        return new ApiResult(code, msg, data);
    }

    public static ApiResult success(Integer code, String msg) {
        return new ApiResult(code, msg);
    }

    public static ApiResult fail(Integer code, String msg) {
        return new ApiResult(code, msg);
    }
}
